package com.hs.activation.common.config;
/*    */ import com.fasterxml.jackson.databind.DeserializationFeature;
/*    */ import com.fasterxml.jackson.databind.ObjectMapper;
/*    */ import com.hs.activation.common.Interceptor.AuthenticationInterceptor;
/*    */ import java.text.SimpleDateFormat;
/*    */ import java.util.List;
/*    */ import org.springframework.context.annotation.Bean;
/*    */ import org.springframework.context.annotation.Configuration;
/*    */ import org.springframework.http.converter.HttpMessageConverter;
/*    */ import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
/*    */ import org.springframework.web.servlet.HandlerInterceptor;
/*    */ import org.springframework.web.servlet.config.annotation.CorsRegistry;
/*    */ import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
/*    */ import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Configuration
/*    */ public class InterceptorConfig
/*    */   extends WebMvcConfigurationSupport
/*    */ {
/*    */   public void addInterceptors(InterceptorRegistry registry) {
/* 27 */     registry.addInterceptor((HandlerInterceptor)authenticationInterceptor())
/* 28 */       .addPathPatterns(new String[] { "/**"
/* 29 */         }).excludePathPatterns(new String[] { "/swagger**/**", "/v3/**", "/swagger-ui/**" });
/*    */   }
/*    */ 
/*    */   
/*    */   @Bean
/*    */   public AuthenticationInterceptor authenticationInterceptor() {
/* 35 */     return new AuthenticationInterceptor();
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   @Bean
/*    */   public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() {
/* 44 */     MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
/* 45 */     ObjectMapper mapper = new ObjectMapper();
/* 46 */     mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
/* 47 */     mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
/* 48 */     converter.setObjectMapper(mapper);
/* 49 */     return converter;
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
/* 56 */     converters.add(jackson2HttpMessageConverter());
/*    */   }
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public void addCorsMappings(CorsRegistry registry) {
/* 63 */     registry.addMapping("/**")
/*    */       
/* 65 */       .allowedOrigins(new String[] { "*"
/*    */         
/* 67 */         }).allowedMethods(new String[] { "POST", "GET", "PUT", "OPTIONS", "DELETE"
/*    */         
/* 69 */         }).maxAge(168000L)
/*    */       
/* 71 */       .allowedHeaders(new String[] { "*" });
/*    */   }
/*    */ }


/* Location:              C:\Users\yzc\Desktop\新建文件夹 (3)\activation-0.0.16.jar!\BOOT-INF\classes\com\hs\activation\common\config\InterceptorConfig.class
 * Java compiler version: 16 (60.0)
 * JD-Core Version:       1.1.3
 */